package com.xinggq.user.api.exception;

import com.xinggq.common.enums.ResponseEnum;
import com.xinggq.common.exception.AbstractCommonException;
import java.io.Serial;
import lombok.Getter;
import lombok.Setter;

/**
 * @Description
 * @Author xinggq
 * @Date 2025/10/30
 */
@Getter
@Setter
public class UserCenterException extends AbstractCommonException {

  @Serial
  private static final long serialVersionUID = 1L;

  private UserCenterException(ResponseEnum responseEnum) {
    super(responseEnum);
  }

  private UserCenterException(ResponseEnum responseEnum, String message) {
    super(responseEnum, message);
  }

  private UserCenterException(ResponseEnum responseEnum, Throwable cause) {
    super(responseEnum, cause);
  }

  private UserCenterException(ResponseEnum responseEnum, String message, Throwable cause) {
    super(responseEnum, message, cause);
  }

  // ==================== 静态工厂方法 ====================

  /**
   * 创建用户不存在异常
   */
  public static UserCenterException userNotFound(String username) {
    return new UserCenterException(ResponseEnum.QUERY_EMPTY, "用户不存在: " + username);
  }

  /**
   * 创建用户创建失败异常
   */
  public static UserCenterException userCreateFailed(String reason) {
    return new UserCenterException(ResponseEnum.REQUEST_FAIL, "用户创建失败: " + reason);
  }

  /**
   * 创建租户超级管理员创建失败异常
   */
  public static UserCenterException tenantSuperAdminCreateFailed(String tenantCode) {
    return new UserCenterException(ResponseEnum.REQUEST_FAIL, "租户超级管理员创建失败: " + tenantCode);
  }

  /**
   * 创建参数错误异常
   */
  public static UserCenterException paramError(String paramName) {
    return new UserCenterException(ResponseEnum.PARAMS_ERROR, "参数错误: " + paramName);
  }

  /**
   * 创建业务错误异常
   */
  public static UserCenterException businessError(String message) {
    return new UserCenterException(ResponseEnum.REQUEST_FAIL, message);
  }

}
